package com.math3d;

/**
 * @Author: clm
 * @Date: 2018-10-15
 */

public class MatrixUtil {
    public final static int mat4_length = 4 * 4;
    public final static int mat4_byte_length = mat4_length * 4;
    public final static void mat4Copy(float[] mat4, float[] target){
        mat4[0] = target[0];
        mat4[1] = target[1];
        mat4[2] = target[2];
        mat4[3] = target[3];

        mat4[4] = target[4];
        mat4[5] = target[5];
        mat4[6] = target[6];
        mat4[7] = target[7];

        mat4[8] = target[8];
        mat4[9] = target[9];
        mat4[10] = target[10];
        mat4[11] = target[11];

        mat4[12] = target[12];
        mat4[13] = target[13];
        mat4[14] = target[14];
        mat4[15] = target[15];
    }
    public final static void mat4CoverMat33(float[] mat4){
        mat4[3] = mat4[7] = mat4[11] = 0;
        mat4[12] = 0;
        mat4[13] = 0;
        mat4[14] = 0;
        mat4[15] = 1;
    }
    public final static void mat4ToMat3(float[] mat4, float[] mat3){
        mat3[0] = mat4[0];
        mat3[1] = mat4[1];
        mat3[2] = mat4[2];

        mat3[3] = mat4[4];
        mat3[4] = mat4[5];
        mat3[5] = mat4[6];

        mat3[6] = mat4[8];
        mat3[7] = mat4[9];
        mat3[8] = mat4[10];
    }
    public final static void mat3ToMat4(float[] mat3, float[] mat4){
        mat4[0] = mat3[0];
        mat4[1] = mat3[1];
        mat4[2] = mat3[2];
        mat4[3] = 0;
        mat4[4] = mat3[3];
        mat4[5] = mat3[4];
        mat4[6] = mat3[5];
        mat4[7] = 0;
        mat4[8] = mat3[6];
        mat4[9] = mat3[7];
        mat4[10] = mat3[8];
        mat4[11] = 0;
        mat4[12] = 0;
        mat4[13] = 0;
        mat4[14] = 0;
        mat4[15] = 1;
    }
    public final static void normalize(float[] mat4){
        mat4[0] = 1;
        mat4[1] = 0;
        mat4[2] = 0;
        mat4[3] = 0;

        mat4[4] = 0;
        mat4[5] = 1;
        mat4[6] = 0;
        mat4[7] = 0;

        mat4[8] = 0;
        mat4[9] = 0;
        mat4[10] = 1;
        mat4[11] = 0;

        mat4[12] = 0;
        mat4[13] = 0;
        mat4[14] = 0;
        mat4[15] = 1;
    }
}
